package com.giscloud.limp.controller;

import java.util.Arrays;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;

import com.giscloud.limp.entity.CaseClose;
import com.giscloud.limp.service.CaseCloseService;
import com.giscloud.limp.entity.dto.CaseCloseDTO;
import com.giscloud.datasource.page.PageInfo;
import com.giscloud.commons.model.Result;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.*;


/**
 * 案件结案信息
 *
 * @author giscloud
 * @email giscloud@giscloud.com
 * @date 2020-06-18 18:57:10
 */
@RestController
@RequestMapping("/limp/caseclose")
@Log4j2
public class CaseCloseController {

    private final CaseCloseService caseCloseService;

    @Autowired
    public CaseCloseController(CaseCloseService caseCloseService) {
        this.caseCloseService = caseCloseService;
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody CaseClose caseClose){
        if(caseClose.getCaseId() == null){
            return Result.error(-1,"caseId 必填");
        }
        return caseCloseService.save(caseClose);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody CaseClose caseClose){
        return caseCloseService.updateById(caseClose);
    }

    /**
     * 删除(直接传数组对象即可，如：[1],[1,2]支持批量删除)
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody Integer[] caseCloseIds){
        return caseCloseService.removeByIds(Arrays.asList(caseCloseIds));
    }

}
